// 所有用到的 echarts option 都在这里进行配置
export const chartOption = {
  testOption(data: any, dimensions: any) {
    const option = {
      grid: {
        left: '2%',
        right: '2%',
        bottom: '10%',
        containLabel: true,
      },
      legend: {
        top: 'bottom',
        textStyle: {
          color: '#999',
        },
      },
      tooltip: {
        trigger: 'item',
      },
      dataset: {
        dimensions: dimensions,
        source: data,
      },
      series: [
        {
          name: 'Chart',
          type: 'pie',
          radius: [50, 130],
          center: ['50%', '50%'],
          roseType: 'area',
          itemStyle: {
            borderRadius: 1,
            color: function (params: any) {
              //自定义颜色
              const colorList = ['#409EFF', '#67C23A', '#E6A23C', '#F56C6C'];
              return colorList[params.dataIndex];
            },
          },
          encode: {
            itemName: dimensions[0],
            value: dimensions[1],
            tooltip: dimensions[1],
          },
        },
      ],
    };
    return option;
  },
};
